class Complex:  
    def __init__(self, real, imag):  
        self.real = real #实部 
        self.imag = imag #虚部
  
    def __add__(self, other):#加法  
        return Complex(self.real + other.real, self.imag + other.imag)  
  
    def __sub__(self, other):#减法  
        return Complex(self.real - other.real, self.imag - other.imag)  
  
    def __mul__(self, other):#乘法  
        real_part = self.real * other.real - self.imag * other.imag  
        imag_part = self.real * other.imag + self.imag * other.real  
        return Complex(real_part, imag_part)  
  
    def __truediv__(self, other):#除法
        denominator = other.real ** 2 + other.imag ** 2  
        real_part = (self.real * other.real + self.imag * other.imag) / denominator  
        imag_part = (self.imag * other.real - self.real * other.imag) / denominator  
        return Complex(real_part, imag_part)  
  
    def __str__(self):  
        return f"{self.real} + {self.imag}j"  
  
c1 = Complex(2, 4)  
c2 = Complex(4, 2)  
  
# 调用 +、-、*、/ 来查看复数运算的结果  
print(c1 + c2)  # 加法  
print(c1 - c2)  # 减法  
print(c1 * c2)  # 乘法  
print(c1 / c2)  # 除法